import {
	DERedirectViewActionType,
	IDERedirectViewAbility,
	IDERedirectViewControllerParams,
	IDERedirectViewModel,
	IDERedirectViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取实体重定向视图输入参数
 *
 * @export
 * @return {*}
 */
export function useDERedirectViewProps() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取实体重定向视图基础
 *
 * @export
 * @param {IDERedirectViewModel} model 实体重定向视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useDERedirectViewBasic(
	model: IDERedirectViewModel,
	props: IParam
) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
	};
}

/**
 * 实体重定向视图行为
 *
 * @export
 */
export function useDERedirectViewAction(controller: any) {
	return {
		...useViewAction(controller),
	};
}

/**
 * 获取实体重定向视图控制器输入参数
 *
 * @export
 * @param {IDERedirectViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<DERedirectViewActionType, IDERedirectViewAbility>>} evt
 * @return {*}  {IDERedirectViewControllerParams<DERedirectViewActionType, IDERedirectViewAbility>}
 */
export function useDERedirectViewControllerParams(
	model: IDERedirectViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<DERedirectViewActionType, IDERedirectViewAbility>>
): IDERedirectViewControllerParams<
	DERedirectViewActionType,
	IDERedirectViewAbility
> {
	return {
		...useViewControllerParams<IDERedirectViewStore, IDERedirectViewModel>(
			model,
			props,
			evt
		),
	};
}
